<%@page import="java.util.Map"%>
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@page import="org.apache.commons.fileupload.FileItem"%>
<%@page import="java.util.List"%>
<%@page import="com.pet.server.ext.util.CookieHelper"%>
<%@page import="com.pet.server.ext.util.ParamHelper"%>
<%
    try{
        request.setCharacterEncoding("UTF-8");        
    }catch(Exception e){
        e.printStackTrace();
    }
    ParamHelper paramHelper = ParamHelper.newInstance();
    // fetch cookie
	String myCookieValue = null;
	Cookie[] cookies = request.getCookies();
	if (cookies != null) {
	    for (Cookie cookie : cookies) {
	        if (CookieHelper.FIELD_NAME.equals(cookie.getName())) {
	        myCookieValue = cookie.getValue();
	    }
	}    
	}
    // handle file
    List<FileItem> fileItemList = null;
    if (ServletFileUpload.isMultipartContent(request)) {
        ServletFileUpload sfu = paramHelper.createFileUploader();
        fileItemList = sfu.parseRequest(request); 
    }
    // fetch params
    Map<String, String[]> parameterMap = request.getParameterMap();
    //System.out.println("==================================================");
    paramHelper.execute(parameterMap, fileItemList, myCookieValue,request,response);
%>